var pageii = null;
var grid = null;
$(function() {
	
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "user_name",
			name : "用户名",
		},{
			colkey : "user_account",
			name : "账号",
			
		}],
		jsonUrl : rootPath + '/system/roleInfo/showByPage.shtml',
		checkbox : true,
		checkValue : 'user_id',
		serNumber : true,
		pageSize:10,
	});
	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();// 初始化传参数
		grid.setOptions({
			data : searchParams
		});
	});
	$("#addBtn").click("click", function() {
		addBtn();
	});
	$("#editAccount").click("click", function() {
		editAccount();
	});
	$("#delAccount").click("click", function() {
		delAccount();
	});
	$("#permissions").click("click", function() {
		permissions();
	});
	$("#role").click("click", function() {
		role();
	});
});
function addBtn() {
	var roleId=$("#roleId").val();
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		tips("请选择需要增加的项",1);
		return;
	}
	confirm('你确定要增加吗？', function() {
		var url = rootPath + '/system/roleInfo/addUserRoleEntity.shtml?roleId='+roleId;
		var s = CommnUtil.ajax(url, {
			ids : cbox.join(",")
		}, "json");
		if(s=="success"){
			tips("新增成功");
			window.location.href = ( rootPath + "/system/roleInfo/findUserRole.shtml?role_id="+roleId);
			
		}else{
			tips("新增失败");
		}
	});
	
}
function loadData(){
	var searchParams = $("#searchForm").serializeJson();// 初始化传参数
	grid.setOptions({
		data : searchParams
	});
}

function confirm(title,yes,no){
	 Wind.use("artDialog", "iframeTools", function () {
		art.dialog.confirm(title, function () {
			if(yes){
				yes()
			}
		}, function () {
			if(no){
				no()
			}
		});
	 });
}


